local hero = fk.CreateSkill{
  name = "hero",
  tags = { Skill.Limited },
}

Fk:loadTranslationTable{
  ["hero"] = "英雄",
  [":hero"] = "限定技，当一名角色处于濒死状态时，你可以减1点体力上限，失去1点体力并令其回复体力至1点，然后你获得〖决心〗。",

  ["#hero-invoke"] = "英雄：是否令 %dest 回复体力至1点，你失去1点体力并减1点体力上限，获得技能〖决心〗。",

  ["$hero"] = "狂风呼啸，不灭的安黛因！",
}

hero:addEffect(fk.EnterDying, {
  can_trigger = function(self, event, target, player, data)
    return player:hasSkill(hero.name) and
      player:usedSkillTimes(hero.name, Player.HistoryGame) == 0
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    if room:askToSkillInvoke(player, {
      skill_name = hero.name,
      prompt = "#hero-invoke::"..target.id,
    }) then
      event:setCostData(self, {tos = {target}})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    room:changeMaxHp(player, -1)
    room:changeHp(player, -1)
    room:recover {
      who = target,
      num = 1 - target.hp,
      recoverBy = player,
      skillName = hero.name,
    }
    if player.dead then return end
    room:handleAddLoseSkills(player, "determination")
  end,
})

return hero
